extends PlayerStatusBase

func start() ->void:
	actor.play_animation("fall")
	
# 物理桢，处理碰撞的逻辑
func run_physics_process(delta):
	var collision_info = actor.move_and_collision_info()
	if collision_info.get("is_on_floor"):
		if actor.velocity.x == 0:
			return change_status("Landing")
		else:
			if collision_info.get("last_velocity").y < 500:
				return change_status("Run")
			else:
				return change_status("Landing")
		return

	if collision_info.get("is_on_wall") && actor.can_wall_slide():
		return change_status("WallSlide")
			
# 逻辑桢，处理画面的逻辑
func run_process(delta):	
	if actor.can_jump():
		return change_to_jump()
		
	if actor.can_sliding():
		return change_status("SlidingStart")
		 
	if actor.can_attack(1):
		return change_status("Attack1")
	
	fall_velocity(delta)
	
# 增加惯性,当没有按钮时按原来的方向走
func fall_velocity(delta:float)->void:
	move_y(delta)
		
	var direction := actor.get_direction()
	if direction != 0:
		move_toward_x(10*delta, 1.0, direction)
	else:
		move_toward_x(5*delta, 0)
		
	actor.refresh_face_direction()
